Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / Object Class Definitions


Application

An object of class Application is the Finder application itself, the outermost container for most Finder objects.

Because of its role as the application that controls the Macintosh desktop, the Finder defines its own application object differently from the way most other applications define their application objects. For an introduction to the role of the application object in scripts that control the Finder, see "The Finder Application Object," which begins on page 18.

PROPERTIES
about this macintosh
A list of references that identify the processes shown in the About This Macintosh window. This list includes a reference to system software but doesn't include a separate reference to the Finder.
Class: List of references to processes
Modifiable: No
apple menu items folder
A reference to the Apple Menu Items folder in the System Folder. The contents of this folder appear in the Apple menu.
Class: Reference
Modifiable: No
clipboard
A reference to the Clipboard window, which can also be displayed by choosing Show Clipboard from the Edit menu.
Class: Reference
Modifiable: No
control panels folder
A reference to the Control Panels folder in the System Folder. This folder is used to store control panels.
Class: Reference
Modifiable: No
desktop
A reference to the desktop.
Class: Reference
Modifiable: No
extensions folder
A reference to the Extensions folder in the System Folder. This folder is used to store extension files.
Class: Reference
Modifiable: No
file sharing
A Boolean value that indicates whether file sharing is on (true) or off (false).
Class: Boolean
Modifiable: Yes
fonts folder
A reference to the Fonts folder in the System Folder. This folder contains the fonts currently available to the system software.
Class: Folder
Modifiable: No
frontmost
A Boolean value that indicates whether the Finder is the frontmost application (true) or not (false).
Class: Boolean
Modifiable: Yes
insertion location
A reference to the object to which new information can currently be added (see page 24 for more information).
Class: Container window
Modifiable: No
largest free block
An integer that indicates the size, in bytes, of the largest free block of process memory available. This value is approximately the same as the value labeled Largest Unused Block in the About This Macintosh window, except that the value in the window is given in kilobytes (K, where 1K = 1024 bytes).
Class: Integer
Modifiable: No
preferences folder
A reference to the Preferences folder in the System Folder. This folder contains application preferences files.
Class: Reference
Modifiable: No
product version
A string that describes the version of system software running on the same computer as the Finder.
Class: String
Modifiable: No
selection
A list of references to the object or objects that are currently selected. The objects in the selection are those that would be cut by a Cut command or copied by a Copy command. If no objects are selected, the value of the Selection property is an empty list.
Class: List of references
Modifiable: Yes
sharing starting up
A Boolean value that indicates whether file sharing is in the process of starting up (true) or not (false).
Class: Boolean
Modifiable: No
shortcuts
A reference to the Finder Shortcuts window, which can also be displayed by choosing Finder Shortcuts from the Help menu.
Class: Reference
Modifiable: No
shutdown items folder
A reference to the Shutdown Items folder in the System Folder. The contents of this folder are automatically opened when the computer is shut down.
Class: Reference
Modifiable: No
startup items folder
A reference to the Startup Items folder in the System Folder.
The contents of this folder are automatically opened when
the computer starts up.
Class: Reference
Modifiable: No
system folder
A reference to the System Folder.
Class: Reference
Modifiable: No
temporary items folder
A reference to the Temporary Items folder in the System Folder. Applications use this folder to store temporary items.
Class: Reference
Modifiable: No
version
A string that describes the version of the Finder Scripting Extension or, for versions of Finder scripting software that
don't require this extension, the version of the Finder file in
the active System Folder.
Class: String
Modifiable: No
view preferences
A reference to the Views control panel.
Class: String
Modifiable: No
visible
A Boolean value that indicates whether the Finder is currently visible (true) or hidden (false).
Class: Boolean
Modifiable: Yes
ELEMENT CLASSES
The Finder application can contain objects of any of the classes listed here. Page numbers indicate the locations of corresponding definitions in this chapter.

Accessory Suitcase (page 27)
Alias File (page 28)
Application File (page 38)
Container (page 42)
Container Window (page 46)
Content Space (page 50)
Control Panel (page 51)
Desk Accessory File (page 54)
Desktop-Object (page 55)
Disk (page 57)
Document File (page 59)
File (page 60)
Folder (page 62)
Font File (page 64)
Font Suitcase (page 65)
Information Window (page 68)
Item (page 72)
Sharable Container (page 78)
Sharing Window (page 83)
Sound File (page 86)
Suitcase (page 88)
Trash-Object (page 90)
Window (page 93)
Elements of any of these classes can be identified by name or by number. With the exception of the desktop and window objects such as container windows and information windows, an element of the Finder can also be identified by
an AppleScript alias record--that is, a representation of an object, much like
an alias icon on the desktop, that identifies the object. For example, both these statements refer to the same file:

alias "Hard Disk:MyFile"file "MyFile" of disk "Hard Disk"
In most cases the Finder can accept a reference like the first example, but you can't use a Finder reference like the second example outside of a Tell statement addressed to the Finder. This book describes how to use Finder references. For information about AppleScript references to alias records, files, applications, machines, and zones, see the AppleScript Language Guide.

Objects of class Application File, Disk, and Folder can also be identified by ID. The ID in each case consists of the application file's creator type (as a string), the disk's ID, and the folder's folder ID, respectively. For example, this statement identifies the startup disk:

disk ID -1
---result: startup disk of application "Finder"
This statement identifies a folder:

folder ID 918 of startup disk
---result: folder "My Folder" of startup disk of application 
"Finder"
This statement identifies the TeachText application:

application file id "ttxt"---result: file "TeachText 7.1" of startup disk of 
application "Finder"
You can identify the frontmost window that lies under a particular point on the desktop by running a script like this:

tell application "Finder"   content space {100,100}
end tell

--result: window of folder "Projects" of startup disk of 
application "Finder"
The pair of integers in braces in the preceding example identifies the point
in which you're interested, and the result contains a reference to the window that contains that point. It is usually easiest to use the term Content Space
to obtain this kind of reference, because the script returns a reference even
if the point is located on the desktop or in some specialized window such as
an Information Window.

You can also specify more restricted window classes, such as Window, Container Window, Information Window, and so on. For example, if
you request a reference to a container window for a point that's located
in some other kind of window, the Finder returns an error.

COMMANDS HANDLED
Clean Up, Computer, Count, Data Size, Exists, Get, Print, Quit, Restart, Select, Shut Down, Sleep, Sort

DEFAULT VALUE CLASS RETURNED
Reference.

EXAMPLES
This script turns on the Calculate Folder Sizes property of the Views
control panel:

tell application "Finder"   set calculate folder sizes of view preferences to true
end tell
This script turns on file sharing for the local computer.

tell application "Finder"   set file sharing to true
end tell
The next example selects all the unselected items in the active window.

tell application "Finder"   repeat with x in front window
      set selected of x to not selected of x
   end repeat
end tell  
NOTES
Although Startup Disk and Trash are properties of the desktop object, you can also refer to them as if they were properties of the Finder. Thus, the Finder interprets both of these statements are references to whatever disk is currently the startup disk:

startup disk
startup disk of desktop
Similarly, the Finder interprets both of these statements as a reference to
the Trash:

trash
trash of desktop

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996